/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package pkl53.model;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author HP G42 (RILLA)
 */
@Entity
@Table(name = "kelurahan")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Kelurahan.findAll", query = "SELECT k FROM Kelurahan k"),
    @NamedQuery(name = "Kelurahan.findByB1r1", query = "SELECT k FROM Kelurahan k WHERE k.kelurahanPK.b1r1 = :b1r1"),
    @NamedQuery(name = "Kelurahan.findByB1r2", query = "SELECT k FROM Kelurahan k WHERE k.kelurahanPK.b1r2 = :b1r2"),
    @NamedQuery(name = "Kelurahan.findByB1r3", query = "SELECT k FROM Kelurahan k WHERE k.kelurahanPK.b1r3 = :b1r3"),
    @NamedQuery(name = "Kelurahan.findByNamaKelurahan", query = "SELECT k FROM Kelurahan k WHERE k.namaKelurahan = :namaKelurahan")})
public class Kelurahan implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected KelurahanPK kelurahanPK;
    @Basic(optional = false)
    @Column(name = "namaKelurahan")
    private String namaKelurahan;
    @JoinColumn(name = "B1R2", referencedColumnName = "B1R2", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Kecamatan kecamatan;
    @JoinColumn(name = "B1R1", referencedColumnName = "B1R1", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Kecamatan kecamatan1;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "kelurahan")
    private List<NoBs> noBsList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "kelurahan1")
    private List<NoBs> noBsList1;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "kelurahan2")
    private List<NoBs> noBsList2;

    public Kelurahan() {
    }

    public Kelurahan(KelurahanPK kelurahanPK) {
        this.kelurahanPK = kelurahanPK;
    }

    public Kelurahan(KelurahanPK kelurahanPK, String namaKelurahan) {
        this.kelurahanPK = kelurahanPK;
        this.namaKelurahan = namaKelurahan;
    }

    public Kelurahan(String b1r1, String b1r2, String b1r3) {
        this.kelurahanPK = new KelurahanPK(b1r1, b1r2, b1r3);
    }

    public KelurahanPK getKelurahanPK() {
        return kelurahanPK;
    }

    public void setKelurahanPK(KelurahanPK kelurahanPK) {
        this.kelurahanPK = kelurahanPK;
    }

    public String getNamaKelurahan() {
        return namaKelurahan;
    }

    public void setNamaKelurahan(String namaKelurahan) {
        this.namaKelurahan = namaKelurahan;
    }

    public Kecamatan getKecamatan() {
        return kecamatan;
    }

    public void setKecamatan(Kecamatan kecamatan) {
        this.kecamatan = kecamatan;
    }

    public Kecamatan getKecamatan1() {
        return kecamatan1;
    }

    public void setKecamatan1(Kecamatan kecamatan1) {
        this.kecamatan1 = kecamatan1;
    }

    @XmlTransient
    public List<NoBs> getNoBsList() {
        return noBsList;
    }

    public void setNoBsList(List<NoBs> noBsList) {
        this.noBsList = noBsList;
    }

    @XmlTransient
    public List<NoBs> getNoBsList1() {
        return noBsList1;
    }

    public void setNoBsList1(List<NoBs> noBsList1) {
        this.noBsList1 = noBsList1;
    }

    @XmlTransient
    public List<NoBs> getNoBsList2() {
        return noBsList2;
    }

    public void setNoBsList2(List<NoBs> noBsList2) {
        this.noBsList2 = noBsList2;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (kelurahanPK != null ? kelurahanPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Kelurahan)) {
            return false;
        }
        Kelurahan other = (Kelurahan) object;
        if ((this.kelurahanPK == null && other.kelurahanPK != null) || (this.kelurahanPK != null && !this.kelurahanPK.equals(other.kelurahanPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pkl53.model.Kelurahan[ kelurahanPK=" + kelurahanPK + " ]";
    }
    
}
